<?php defined('SYSPATH') or die('No direct script access.'); ?>

<h1>Category Index</h1>
<?php echo Form::open('admin/merchmanagement/categories/add/0');?>
<?php echo Form::input('name', '');?>
<?php echo Form::submit('submit', 'Add Root Category') ?>
<?php echo Form::close();?>

<?php foreach($categories as $category) : ?>
<div>
	<?php echo $category->name; ?>
	<?php echo HTML::anchor('admin/merchmanagement/categories/delete/'.$category->id, "Delete");?>
	<?php echo HTML::anchor('admin/merchmanagement/categories/attributes/'.$category->id, "Manage Attributes");?>
	<ul>
		<?php echo Form::open('admin/merchmanagement/categories/add/'.$category->id)?>
		<?php echo Form::input('name', '');?>
		<?php echo Form::submit('submit', 'Add Subcategory');?>
		<?php echo Form::close();?>
		
		<?php foreach($category->subcategories->find_all() as $sub): ?>
		<li>
			<?php echo $sub->name; ?>
			<?php echo HTML::anchor("admin/merchmanagement/categories/delete/".$sub->id, "Delete");?>
			<?php echo HTML::anchor('admin/merchmanagement/categories/attributes/'.$sub->id, 'Manage Attributes');?>
			<?php echo HTML::anchor('admin/merchmanagement/items/add/'.$sub->id, 'Add Item')?>
		</li>
		<?php endforeach;?>
	</ul>
	<?php endforeach;?>
</div>